package com.ushine.web.communication.des.android;


import java.util.Arrays;
import java.util.Base64;

/**
 * @Author: yls
 * @Date 2022/5/6 13:13
 * @Description: base64转换器
 * @Version 1.0
 **/
public class Base64AndroidUtils {
    private Base64AndroidUtils() {

    }

    /**
     * 功能描述:
     * 〈字节数组转Base64编码〉
     *
     * @param bytes 字节数组
     * @return : java.lang.String
     * @author : yls
     * @date : 2022/5/6 11:18
     */
    public static String byte2Base64(byte[] bytes) {
        return Base64.getEncoder().encodeToString(bytes);
    }

    /**
     * Base64编码转字节数组
     *
     * @param base64Key base64字符串
     * @return 字节数组
     */
    public static byte[] base642Byte(String base64Key) {
        return Base64.getDecoder().decode(base64Key);
    }

    public static void main(String[] args) {
        byte[] bytes = base642Byte("fOi8sCpX0S6yzBnZzwgpte9fy0YaNOjDP6W2oGfrZ+YhY/19kAuLKPdBz9vFYIY1L+ddP2G6bdRX+bB1SmazdjMhHDUQZIHFCsap01QWvnaq/9cbj2xCzY7+s2Aao4bF4u/vJiXsGf7c1uc/Um1lluFGrKP0TZ+t7P7dWeFI+XG6pkGiQNhwWbViBm0PqoAIaREZfkhQp6DfoesoJ8redoUUm2Oc3xdtH+M6rBSvCzO05Hb+sSAQvs+zgTt8bSNkTw+2dEuh2syC+VxehbAyJEEYyGn9W9T1g8y332EZ5nEFAysLIs4/6OtLy/gnfGRKppojyoS0/dfEOu3TWdVgCQ==");
        System.out.println(Arrays.toString(bytes));
    }
}
